class Task26:
    def run(self, tree1, tree2):
        if tree1 is None or tree2 is None:
            return False
        return self.dfs(tree1, tree2)

    def dfs(self, tree1, tree2):
        if tree1 is None:
            return False
        elif self.tree_match(tree1, tree2):
            return True
        else:
            return self.dfs(tree1.left, tree2) or self.dfs(tree1.right, tree2)

    def tree_match(self, tree1, tree2):
        if tree2 is None:
            return True
        elif tree1 is None:
            return False
        elif not self.rough_equal(tree1.val, tree2.val):
            return False
        else:
            return self.tree_match(tree1.left, tree2.left) and self.tree_match(tree1.right, tree2.right)

    def rough_equal(self, num1, num2, eps=1e-5):
        return (num1 - eps) < num2 < (num1 + eps)
